//
// Created by jsjxsy on 2022/7/15.
//
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int cmp_func(const void *a, const void *b) {
  return strcmp(*(char **) a , *(char **) b);
}

int main(void) {
  char *names[] = {
      "Cindy",
      "Don",
      "Andrey",
      "Elsa",
      "George",
      "Frank",
      "Benny",
  };
  printf("排序之前的列表：\n");
  for(int n = 0 ; n < 7; n++ ) {
    printf("%s ", names[n]);
  }
  puts("\n");
  int size = sizeof(names)/sizeof(names[0]);
  qsort(names, size, sizeof(char *), cmp_func);
  printf("排序之后的列表：\n");
  for(int n = 0 ; n < 7; n++ ) {
    printf("%s ", names[n]);
  }
  return 0;
}
